preexperiment_date <- "16 March 2023 11 39AM/All"
postexperiment_date <- "16 March 2023 05 08PM/All"
##--- last fish run in trial ---##
experiment_date <- "16 March 2023 01 42PM/Oxygen"
experiment_date2 <- "16 March 2023 01 42PM/All"
firesting <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1 <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_date2,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) preexperiment_date_asus <- "16 March 2023 11 21AM/All"
postexperiment_date_asus <- "16 March 2023 05 10PM/All"
##--- last fish run in trial ---##
experiment_date_asus <- "16 March 2023 01 00PM/Oxygen"
experiment_date2_asus <- "16 March 2023 01 00PM/All"
firesting_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last_asus <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) chamber1_dell = 0.04650+0.00022
chamber2_dell = 0.04593+0.00022
chamber3_dell = 0.04977+0.00022
chamber4_dell = 0.04860+0.00022
chamber1_asus = 0.04565
chamber2_asus = 0.04573+0.00385
chamber3_asus = 0.04551+0.00322
chamber4_asus = 0.04791+0.00277
Date_tested="2023-03-16"
Clutch = "49"
Male = "CVLA049"
Female = "CVLA098"
Population = "Vlassof cay"
Tank =109
salinity =36
Date_analysed = Sys.Date() Replicate = 1
mass = 0.0004168
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_dell
system1 = "Dell"
Notes="low signal; reliable?"
##--- time of trail ---##
experiment_mmr_date <- "16 March 2023 01 08PM/Oxygen"
experiment_mmr_date2 <- "16 March 2023 01 08PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0003755522
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001464077
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 5 6 7 8 9 10 11 13 15 17 19 20 21 23 24 27 29 30
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.86
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 5 1 189.8906 -0.009447527 0.967 NA 1973 2205 9667.97
## 2: 8 1 189.1124 -0.007973541 0.952 NA 3386 3618 11288.23
## 3: 9 1 213.1412 -0.009629285 0.956 NA 3879 4112 11827.80
## 4: 10 1 205.3676 -0.008568525 0.956 NA 4367 4600 12367.83
## 5: 11 1 230.7873 -0.010171488 0.963 NA 4861 5094 12907.64
## 6: 19 1 293.6439 -0.011236357 0.968 NA 8801 9035 17228.18
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9923.05 98.412 95.961 -0.009447527 -0.0007138551 -0.008733672 -0.008733672
## 2: 11542.58 98.996 96.966 -0.007973541 -0.0008893597 -0.007084181 -0.007084181
## 3: 12082.19 99.168 96.575 -0.009629285 -0.0009478207 -0.008681464 -0.008681464
## 4: 12622.42 99.300 97.405 -0.008568525 -0.0010063401 -0.007562185 -0.007562185
## 5: 13162.69 99.147 96.587 -0.010171488 -0.0010648498 -0.009106639 -0.009106639
## 6: 17483.43 99.986 97.066 -0.011236357 -0.0015329619 -0.009703395 -0.009703395
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.09723761
## 2: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.07887276
## 3: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.09665634
## 4: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.08419468
## 5: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.10139008
## 6: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.10803416
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -233.2956 NA mgO2/hr/kg -233.2956
## 2: -189.2341 NA mgO2/hr/kg -189.2341
## 3: -231.9010 NA mgO2/hr/kg -231.9010
## 4: -202.0026 NA mgO2/hr/kg -202.0026
## 5: -243.2584 NA mgO2/hr/kg -243.2584
## 6: -259.1990 NA mgO2/hr/kg -259.1990
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 1 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004168 | ch4 | Dell | 0.04882 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 233.9313 | 0.0975026 | 0.962 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 4 6 8 10 11 12 13 14 15 17 18 19 21 23 24 25 26 28
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.08 1.55
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 265.1984 -0.03044053 0.9496067 NA 95 149 5541.12
## 2: NA 2 265.3062 -0.03037083 0.9457167 NA 162 216 5617.27
## 3: NA 3 264.7619 -0.03036278 0.9487224 NA 94 148 5540.02
## 4: NA 4 264.2808 -0.03027518 0.9482241 NA 96 150 5542.21
## 5: NA 5 264.7557 -0.03027208 0.9441385 NA 163 217 5618.38
## ---
## 209: NA 209 188.6261 -0.01685264 0.8715175 NA 213 267 5675.28
## 210: NA 210 189.7382 -0.01682741 0.8088166 NA 49 103 5489.09
## 211: NA 211 188.8802 -0.01667190 0.8061398 NA 48 102 5488.01
## 212: NA 212 188.6466 -0.01662885 0.8053402 NA 46 100 5485.82
## 213: NA 213 187.3433 -0.01639304 0.8031721 NA 47 101 5486.91
## endtime oxy endoxy rate
## 1: 5601.12 96.427 94.768 -0.03044053
## 2: 5677.27 94.499 92.984 -0.03037083
## 3: 5600.02 96.391 94.810 -0.03036278
## 4: 5602.21 96.462 94.808 -0.03027518
## 5: 5678.38 94.513 93.072 -0.03027208
## ---
## 209: 5735.28 93.081 91.970 -0.01685264
## 210: 5549.09 97.319 96.314 -0.01682741
## 211: 5548.01 97.335 96.260 -0.01667190
## 212: 5545.82 97.531 96.463 -0.01662885
## 213: 5546.91 97.359 96.412 -0.01639304
##
## Regressions : 213 | Results : 213 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 213 adjusted rate(s):
## Rate : -0.03044053
## Adjustment : -0.0003755522
## Adjusted Rate : -0.03006497
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 172 rate(s) removed, 41 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 40 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 265.1984 -0.03044053 0.9496067 NA 95 149 5541.12
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5601.12 96.427 94.768 -0.03044053 -0.0003755522 -0.03006497 -0.03006497
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04882 0.0004168 NA 36 28.5 1.013253 -0.3347327
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -803.1016 NA mgO2/hr/kg -803.1016
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 1 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004168 | ch4 | Dell | 0.04882 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 233.9313 | 0.0975026 | 0.962 | 803.1016 | 0.3347327 | 0.9496067 | 569.1703 | 0.2372302 | low signal; reliable? |
## Rows: 324 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 2
mass = 0.0004057
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_dell
system1 = "Dell"
Notes="check max;second cycled used; probe got bumped during max"
##--- time of trail ---##
experiment_mmr_date <- "16 March 2023 01 20PM/Oxygen"
experiment_mmr_date2 <- "16 March 2023 01 20PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0005814859
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001254311
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 5 6 7 8 9 10 11 13 15 17 19 20 21 23 24 27 29 30
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.86
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 6 1 213.3592 -0.01110530 0.964 NA 2425 2632 10207.09
## 2: 10 1 242.5469 -0.01151076 0.971 NA 4367 4600 12367.83
## 3: 14 1 273.1815 -0.01190403 0.964 NA 6336 6569 14528.25
## 4: 15 1 271.5604 -0.01136976 0.969 NA 6829 7063 15067.38
## 5: 18 1 295.7977 -0.01173191 0.990 NA 8306 8539 16687.73
## 6: 20 1 308.4833 -0.01174798 0.983 NA 9296 9529 17768.39
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10462.36 99.647 97.021 -0.01110530 -8.758789e-05 -0.01101771 -0.01101771
## 2: 12622.42 99.877 96.905 -0.01151076 -4.823382e-04 -0.01102842 -0.01102842
## 3: 14783.14 99.939 96.950 -0.01190403 -8.771196e-04 -0.01102691 -0.01102691
## 4: 15322.58 99.933 97.056 -0.01136976 -9.756582e-04 -0.01039410 -0.01039410
## 5: 16942.17 99.894 96.970 -0.01173191 -1.271661e-03 -0.01046025 -0.01046025
## 6: 18022.81 99.596 96.492 -0.01174798 -1.469118e-03 -0.01027886 -0.01027886
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1256071
## 2: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1257292
## 3: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1257119
## 4: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1184976
## 5: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1192517
## 6: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.1171839
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -309.6059 NA mgO2/hr/kg -309.6059
## 2: -309.9067 NA mgO2/hr/kg -309.9067
## 3: -309.8643 NA mgO2/hr/kg -309.8643
## 4: -292.0819 NA mgO2/hr/kg -292.0819
## 5: -293.9406 NA mgO2/hr/kg -293.9406
## 6: -288.8437 NA mgO2/hr/kg -288.8437
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 2 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004057 | ch3 | Dell | 0.04999 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 303.0799 | 0.1229595 | 0.9716 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 7 8 9 11 14 16 21 22 23 24 26 28 29 31 33
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.32
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 292.9553 -0.03128207 0.9869906 NA 84 139 6222.97
## 2: NA 2 292.5787 -0.03122210 0.9867554 NA 83 138 6221.88
## 3: NA 3 292.0767 -0.03114140 0.9865958 NA 85 140 6224.05
## 4: NA 4 291.1867 -0.03099976 0.9857142 NA 82 137 6220.80
## 5: NA 5 290.4958 -0.03088844 0.9857584 NA 86 141 6225.13
## ---
## 216: NA 216 200.6267 -0.01638771 0.9137377 NA 5 60 6137.04
## 217: NA 217 195.5339 -0.01556156 0.9140680 NA 4 59 6135.95
## 218: NA 218 190.5020 -0.01474525 0.9110752 NA 3 58 6134.86
## 219: NA 219 186.4062 -0.01408077 0.9045458 NA 2 57 6133.77
## 220: NA 220 183.3455 -0.01358418 0.8975987 NA 1 56 6132.67
## endtime oxy endoxy rate
## 1: 6282.97 98.290 96.441 -0.03128207
## 2: 6281.88 98.250 96.442 -0.03122210
## 3: 6284.05 98.277 96.450 -0.03114140
## 4: 6280.80 98.221 96.462 -0.03099976
## 5: 6285.13 98.205 96.462 -0.03088844
## ---
## 216: 6197.04 99.876 98.805 -0.01638771
## 217: 6195.95 99.853 98.870 -0.01556156
## 218: 6194.86 99.868 98.974 -0.01474525
## 219: 6193.77 99.902 99.065 -0.01408077
## 220: 6192.67 99.927 99.156 -0.01358418
##
## Regressions : 220 | Results : 220 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 220 adjusted rate(s):
## Rate : -0.03128207
## Adjustment : 0.0005814859
## Adjusted Rate : -0.03186355
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 11 rate(s) removed, 209 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 208 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 292.9553 -0.03128207 0.9869906 NA 84 139 6222.97
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6282.97 98.29 96.441 -0.03128207 0.0005814859 -0.03186355 -0.03186355
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04999 0.0004057 NA 36 28.5 1.013253 -0.3632595
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -895.3894 NA mgO2/hr/kg -895.3894
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 2 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004057 | ch3 | Dell | 0.04999 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 303.0799 | 0.1229595 | 0.9716 | 895.3894 | 0.3632595 | 0.9869906 | 592.3095 | 0.2403 | check max;second cycled used; probe got bumped during max |
## Rows: 325 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 3
mass = 0.0004056
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_dell
system1 = "Dell"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "16 March 2023 01 31PM/Oxygen"
experiment_mmr_date2 <- "16 March 2023 01 31PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0007873251
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0006673768
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 5 6 7 8 9 10 11 13 15 17 19 20 21 23 24 27 29 30
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.86
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 6 1 251.6425 -0.014945460 0.995 NA 2425 2632 10207.09
## 2: 16 1 347.3038 -0.015893309 0.997 NA 7318 7551 15607.94
## 3: 17 1 307.6529 -0.012891251 0.988 NA 7812 8045 16147.93
## 4: 18 1 173.4082 -0.004416596 0.959 NA 8306 8539 16687.73
## 5: 19 1 198.0091 -0.005709951 0.982 NA 8801 9035 17228.18
## 6: 20 1 181.4831 -0.004611633 0.958 NA 9296 9529 17768.39
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10462.36 98.903 95.182 -0.014945460 0.0002571451 -0.015202605 -0.015202605
## 2: 15862.47 99.161 95.229 -0.015893309 -0.0005247886 -0.015368520 -0.015368520
## 3: 16402.49 99.255 96.456 -0.012891251 -0.0006029758 -0.012288275 -0.012288275
## 4: 16942.17 99.807 98.634 -0.004416596 -0.0006811246 -0.003735471 -0.003735471
## 5: 17483.43 99.710 98.175 -0.005709951 -0.0007594348 -0.004950516 -0.004950516
## 6: 18022.81 99.721 98.471 -0.004611633 -0.0008375915 -0.003774042 -0.003774042
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.16000344
## 2: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.16174965
## 3: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.12933088
## 4: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.03931485
## 5: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.05210288
## 6: %Air sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.03972080
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -394.48579 NA mgO2/hr/kg -394.48579
## 2: -398.79106 NA mgO2/hr/kg -398.79106
## 3: -318.86312 NA mgO2/hr/kg -318.86312
## 4: -96.93011 NA mgO2/hr/kg -96.93011
## 5: -128.45878 NA mgO2/hr/kg -128.45878
## 6: -97.93097 NA mgO2/hr/kg -97.93097
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 3 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004056 | ch2 | Dell | 0.04615 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 267.7059 | 0.1085815 | 0.984 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 8 10 11 12 14 15 16 17 19 20 21 22 24 25 26 27
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.31
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 327.6996 -0.03346755 0.9918289 NA 71 126 6892.00
## 2: NA 2 327.5687 -0.03344855 0.9918041 NA 72 127 6893.09
## 3: NA 3 326.6350 -0.03331371 0.9918034 NA 70 125 6890.91
## 4: NA 4 326.3342 -0.03326992 0.9910515 NA 73 128 6894.17
## 5: NA 5 325.3956 -0.03313460 0.9917476 NA 69 124 6889.81
## ---
## 214: NA 214 246.6836 -0.02169220 0.9645195 NA 5 60 6819.42
## 215: NA 215 245.2789 -0.02148682 0.9653371 NA 4 59 6818.33
## 216: NA 216 243.1412 -0.02117430 0.9671803 NA 3 58 6817.25
## 217: NA 217 241.5122 -0.02093573 0.9706096 NA 2 57 6816.16
## 218: NA 218 239.6443 -0.02066260 0.9719372 NA 1 56 6815.07
## endtime oxy endoxy rate
## 1: 6952.00 97.018 94.987 -0.03346755
## 2: 6953.09 97.008 95.020 -0.03344855
## 3: 6950.91 97.040 95.024 -0.03331371
## 4: 6954.17 96.968 95.079 -0.03326992
## 5: 6949.81 97.038 95.141 -0.03313460
## ---
## 214: 6879.42 98.764 97.347 -0.02169220
## 215: 6878.33 98.764 97.338 -0.02148682
## 216: 6877.25 98.860 97.336 -0.02117430
## 217: 6876.16 98.798 97.431 -0.02093573
## 218: 6875.07 98.808 97.458 -0.02066260
##
## Regressions : 218 | Results : 218 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 218 adjusted rate(s):
## Rate : -0.03346755
## Adjustment : 0.0007873251
## Adjusted Rate : -0.03425488
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 218 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 217 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time endtime
## 1: NA 1 327.6996 -0.03346755 0.9918289 NA 71 126 6892 6952
## oxy endoxy rate adjustment rate.adjusted rate.input oxy.unit
## 1: 97.018 94.987 -0.03346755 0.0007873251 -0.03425488 -0.03425488 %Air
## time.unit volume mass area S t P rate.abs rate.m.spec
## 1: sec 0.04615 0.0004056 NA 36 28.5 1.013253 -0.3605236 -888.8649
## rate.a.spec output.unit rate.output
## 1: NA mgO2/hr/kg -888.8649
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 3 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004056 | ch2 | Dell | 0.04615 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 267.7059 | 0.1085815 | 0.984 | 888.8649 | 0.3605236 | 0.9918289 | 621.1589 | 0.2519421 |
## Rows: 326 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 4
mass = 0.0006842
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_dell
system1 = "Dell"
Notes="first cycle not reliable; second cycle used"
##--- time of trail ---##
experiment_mmr_date <- "16 March 2023 01 42PM/Oxygen"
experiment_mmr_date2 <- "16 March 2023 01 42PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",experiment_mmr_date2,"slopes/Cycle_2.txt"), # custom
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.000615187
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.000699055
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 5 6 7 8 9 10 11 13 15 17 19 20 21 23 24 27 29 30
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.86
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 1 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 8 1 216.2361 -0.010424204 0.981 NA 3386 3618 11288.23
## 2: 9 1 196.7009 -0.008296604 0.983 NA 3879 4112 11827.80
## 3: 17 1 283.3146 -0.011420001 0.985 NA 7812 8045 16147.93
## 4: 18 1 300.7640 -0.012108596 0.985 NA 8306 8539 16687.73
## 5: 19 1 303.3219 -0.011873558 0.991 NA 8801 9035 17228.18
## 6: 21 1 309.2604 -0.011501147 0.964 NA 9784 10017 18307.41
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 11542.58 98.423 95.651 -0.010424204 -0.0006547745 -0.009769429 -0.009769429
## 2: 12082.19 98.423 96.269 -0.008296604 -0.0006592788 -0.007637325 -0.007637325
## 3: 16402.49 98.904 95.832 -0.011420001 -0.0006953420 -0.010724659 -0.010724659
## 4: 16942.17 98.542 95.483 -0.012108596 -0.0006998476 -0.011408749 -0.011408749
## 5: 17483.43 98.608 95.665 -0.011873558 -0.0007043624 -0.011169195 -0.011169195
## 6: 18561.82 98.445 95.459 -0.011501147 -0.0007133678 -0.010787779 -0.010787779
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.10409063
## 2: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.08137363
## 3: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.11426835
## 4: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.12155713
## 5: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.11900476
## 6: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.11494087
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -152.1348 NA mgO2/hr/kg -152.1348
## 2: -118.9325 NA mgO2/hr/kg -118.9325
## 3: -167.0102 NA mgO2/hr/kg -167.0102
## 4: -177.6632 NA mgO2/hr/kg -177.6632
## 5: -173.9327 NA mgO2/hr/kg -173.9327
## 6: -167.9931 NA mgO2/hr/kg -167.9931
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 4 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0006842 | ch1 | Dell | 0.04672 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 167.7468 | 0.1147723 | 0.9812 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 7.98
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 4 5 7 8 10 11 12 13 15 16 17 18 19 21 22 24 25 26
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.07 1.27
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 401.9081 -0.03788613 0.9934378 NA 186 241 8235.48
## 2: NA 2 400.9497 -0.03777007 0.9932784 NA 187 242 8236.56
## 3: NA 3 400.4579 -0.03770919 0.9947312 NA 196 251 8246.36
## 4: NA 4 400.0996 -0.03766759 0.9927035 NA 185 240 8234.39
## 5: NA 5 399.7026 -0.03761753 0.9943094 NA 197 252 8247.44
## ---
## 216: NA 216 299.8495 -0.02546687 0.9429084 NA 116 171 8158.83
## 217: NA 217 298.3754 -0.02528418 0.9431464 NA 112 167 8154.45
## 218: NA 218 298.0179 -0.02524272 0.9441384 NA 115 170 8157.74
## 219: NA 219 297.8747 -0.02522398 0.9441094 NA 113 168 8155.54
## 220: NA 220 297.0961 -0.02512955 0.9450654 NA 114 169 8156.64
## endtime oxy endoxy rate
## 1: 8295.48 89.904 87.630 -0.03788613
## 2: 8296.56 89.888 87.642 -0.03777007
## 3: 8306.36 89.425 87.290 -0.03770919
## 4: 8294.39 89.804 87.649 -0.03766759
## 5: 8307.44 89.422 87.315 -0.03761753
## ---
## 216: 8218.83 92.116 90.380 -0.02546687
## 217: 8214.45 92.481 90.536 -0.02528418
## 218: 8217.74 92.200 90.421 -0.02524272
## 219: 8215.54 92.405 90.446 -0.02522398
## 220: 8216.64 92.311 90.490 -0.02512955
##
## Regressions : 220 | Results : 220 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 220 adjusted rate(s):
## Rate : -0.03788613
## Adjustment : -0.000615187
## Adjusted Rate : -0.03727094
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 220 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 219 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 401.9081 -0.03788613 0.9934378 NA 186 241 8235.48
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8295.48 89.904 87.63 -0.03788613 -0.000615187 -0.03727094 -0.03727094
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04672 0.0006842 NA 36 28.5 1.013253 -0.3971118
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -580.4031 NA mgO2/hr/kg -580.4031
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 4 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0006842 | ch1 | Dell | 0.04672 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 167.7468 | 0.1147723 | 0.9812 | 580.4031 | 0.3971118 | 0.9934378 | 412.6563 | 0.2823394 | first cycle not reliable; second cycle used |
## Rows: 327 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 5
mass = 0.0005078
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "16 March 2023 12 26PM/Oxygen"
experiment_mmr_date2_asus <- "16 March 2023 12 26PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0004844282
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0001921157
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.61
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.45
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2_asus$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 10 1 275.8402 -0.01614619 0.992 NA 3612 3801 10915.81
## 2: 12 1 293.4695 -0.01617223 0.997 NA 4410 4598 11995.53
## 3: 15 1 305.8898 -0.01512215 0.979 NA 5607 5795 13615.63
## 4: 16 1 307.2178 -0.01464344 0.965 NA 6006 6195 14155.51
## 5: 17 1 317.9671 -0.01482995 0.961 NA 6405 6593 14695.59
## 6: 18 1 312.6745 -0.01395240 0.952 NA 6804 6993 15236.11
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 11171.57 99.242 95.299 -0.01614619 -2.501620e-04 -0.01589602 -0.01589602
## 2: 12250.06 99.235 95.217 -0.01617223 -2.117410e-04 -0.01596048 -0.01596048
## 3: 13870.10 99.592 95.863 -0.01512215 -1.540593e-04 -0.01496809 -0.01496809
## 4: 14411.09 99.446 95.989 -0.01464344 -1.348174e-04 -0.01450862 -0.01450862
## 5: 14950.29 99.473 95.918 -0.01482995 -1.156039e-04 -0.01471435 -0.01471435
## 6: 15491.74 99.483 96.119 -0.01395240 -9.634239e-05 -0.01385606 -0.01385606
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1837235
## 2: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1844685
## 3: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1729986
## 4: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1676881
## 5: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1700659
## 6: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.1601459
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -361.8029 NA mgO2/hr/kg -361.8029
## 2: -363.2700 NA mgO2/hr/kg -363.2700
## 3: -340.6826 NA mgO2/hr/kg -340.6826
## 4: -330.2247 NA mgO2/hr/kg -330.2247
## 5: -334.9072 NA mgO2/hr/kg -334.9072
## 6: -315.3720 NA mgO2/hr/kg -315.3720
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 5 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0005078 | ch4 | Asus | 0.05068 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 346.1775 | 0.1757889 | 0.9788 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.61
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.50
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 257.9806 -0.04001623 0.9797025 NA 15 60 3982.74
## 2: NA 2 257.3812 -0.03986684 0.9795583 NA 14 59 3981.39
## 3: NA 3 257.2480 -0.03983348 0.9793856 NA 16 61 3984.12
## 4: NA 4 257.1928 -0.03981678 0.9797655 NA 20 65 3989.57
## 5: NA 5 256.9374 -0.03975439 0.9794313 NA 19 64 3988.21
## ---
## 174: NA 174 192.1313 -0.02391513 0.9884750 NA 141 186 4153.26
## 175: NA 175 191.5665 -0.02377758 0.9898791 NA 137 182 4147.85
## 176: NA 176 191.4374 -0.02374845 0.9897441 NA 140 185 4151.88
## 177: NA 177 190.6871 -0.02356827 0.9910214 NA 139 184 4150.55
## 178: NA 178 190.6671 -0.02356292 0.9910474 NA 138 183 4149.20
## endtime oxy endoxy rate
## 1: 4042.74 98.607 96.173 -0.04001623
## 2: 4041.39 98.532 96.130 -0.03986684
## 3: 4044.12 98.608 96.214 -0.03983348
## 4: 4049.57 98.255 96.041 -0.03981678
## 5: 4048.21 98.324 96.096 -0.03975439
## ---
## 174: 4213.26 92.867 91.261 -0.02391513
## 175: 4207.85 93.072 91.554 -0.02377758
## 176: 4211.88 92.887 91.306 -0.02374845
## 177: 4210.55 92.943 91.399 -0.02356827
## 178: 4209.20 93.032 91.479 -0.02356292
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.04001623
## Adjustment : -0.0004844282
## Adjusted Rate : -0.0395318
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 178 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 177 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 257.9806 -0.04001623 0.9797025 NA 15 60 3982.74
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 4042.74 98.607 96.173 -0.04001623 -0.0004844282 -0.0395318 -0.0395318
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.05068 0.0005078 NA 36 28.5 1.013253 -0.4569017
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -899.7671 NA mgO2/hr/kg -899.7671
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 5 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0005078 | ch4 | Asus | 0.05068 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 346.1775 | 0.1757889 | 0.9788 | 899.7671 | 0.4569017 | 0.9797025 | 553.5896 | 0.2811128 | ||
| ### Expor | ting data |
## Rows: 328 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 6
mass = 0.0004363
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "16 March 2023 12 37PM/Oxygen"
experiment_mmr_date2_asus <- "16 March 2023 12 37PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001349259
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.002462994
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.61
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.45
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 7 1 228.0998 -0.01383943 0.992 NA 2413 2595 9296.57
## 2: 10 1 271.8736 -0.01578420 0.993 NA 3612 3793 10915.81
## 3: 17 1 344.6200 -0.01664191 0.980 NA 6405 6586 14695.59
## 4: 19 1 357.0387 -0.01629970 0.994 NA 7203 7384 15775.77
## 5: 20 1 361.2333 -0.01601218 0.996 NA 7602 7783 16315.95
## 6: 21 1 313.3653 -0.01265250 0.983 NA 8001 8182 16856.62
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9541.90 99.399 95.864 -0.01383943 -0.002021466 -0.011817962 -0.011817962
## 2: 11160.76 99.366 95.613 -0.01578420 -0.002241100 -0.013543105 -0.013543105
## 3: 14940.81 99.699 95.805 -0.01664191 -0.002753868 -0.013888043 -0.013888043
## 4: 16020.80 99.723 95.777 -0.01629970 -0.002900388 -0.013399311 -0.013399311
## 5: 16561.19 99.806 95.937 -0.01601218 -0.002973681 -0.013038499 -0.013038499
## 6: 17102.01 99.951 96.496 -0.01265250 -0.003047036 -0.009605467 -0.009605467
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1313344
## 2: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1505062
## 3: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1543395
## 4: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1489082
## 5: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1448984
## 6: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.1067467
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -301.0186 NA mgO2/hr/kg -301.0186
## 2: -344.9602 NA mgO2/hr/kg -344.9602
## 3: -353.7463 NA mgO2/hr/kg -353.7463
## 4: -341.2976 NA mgO2/hr/kg -341.2976
## 5: -332.1073 NA mgO2/hr/kg -332.1073
## 6: -244.6636 NA mgO2/hr/kg -244.6636
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 6 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004363 | ch3 | Asus | 0.04873 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 334.626 | 0.1459973 | 0.991 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.61
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 16 17 19 21 22 23 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.57
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 291.6430 -0.04101864 0.9963889 NA 116 161 4797.39
## 2: NA 2 291.3440 -0.04095715 0.9962673 NA 115 160 4796.03
## 3: NA 3 291.2470 -0.04093767 0.9962154 NA 114 159 4794.67
## 4: NA 4 290.9991 -0.04088470 0.9960271 NA 117 162 4798.73
## 5: NA 5 290.8201 -0.04084999 0.9959073 NA 113 158 4793.34
## ---
## 173: NA 173 186.9240 -0.01942315 0.9161755 NA 149 194 4841.96
## 174: NA 174 186.3147 -0.01929229 0.9186854 NA 145 190 4836.58
## 175: NA 175 185.8695 -0.01920492 0.9207900 NA 148 193 4840.62
## 176: NA 176 185.0028 -0.01902427 0.9233788 NA 146 191 4837.94
## 177: NA 177 184.9242 -0.01900951 0.9236171 NA 147 192 4839.28
## endtime oxy endoxy rate
## 1: 4857.39 94.842 92.433 -0.04101864
## 2: 4856.03 94.882 92.519 -0.04095715
## 3: 4854.67 94.900 92.575 -0.04093767
## 4: 4858.73 94.816 92.443 -0.04088470
## 5: 4853.34 94.907 92.612 -0.04084999
## ---
## 173: 4901.96 93.038 91.477 -0.01942315
## 174: 4896.58 93.339 91.743 -0.01929229
## 175: 4900.62 93.020 91.572 -0.01920492
## 176: 4897.94 93.214 91.719 -0.01902427
## 177: 4899.28 93.105 91.647 -0.01900951
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.04101864
## Adjustment : -0.001349259
## Adjusted Rate : -0.03966938
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 37 rate(s) removed, 140 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 139 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 291.643 -0.04101864 0.9963889 NA 116 161 4797.39
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 4857.39 94.842 92.433 -0.04101864 -0.001349259 -0.03966938 -0.03966938
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04873 0.0004363 NA 36 28.5 1.013253 -0.4408506
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1010.43 NA mgO2/hr/kg -1010.43
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 6 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004363 | ch3 | Asus | 0.04873 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 334.626 | 0.1459973 | 0.991 | 1010.43 | 0.4408506 | 0.9963889 | 675.804 | 0.2948533 | ||
| ### Expor | ting data |
## Rows: 329 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 7
mass = 0.0002565
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_asus
system1 = "Asus"
Notes="check max"
##--- time of trail ---##
experiment_mmr_date_asus <- "16 March 2023 12 49PM/Oxygen"
experiment_mmr_date2_asus <- "16 March 2023 12 49PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_4.txt", # custom
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0005683739
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
#bg_post3 <- post_cycle3 %>% calc_rate.bg()
bg_post <- mean(bg_post1$rate.bg.mean,bg_post2$rate.bg.mean) #,bg_post3$rate.bg.mean)
bg_post ## [1] -0.003685839
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.61
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.45
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 7 rate(s) removed, 14 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 8 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 6 1 137.1471 -0.004274315 0.990 NA 2013 2195 8756.57
## 2: 8 1 143.0661 -0.004397465 0.986 NA 2813 2995 9835.87
## 3: 11 1 194.1857 -0.008233730 0.994 NA 4011 4192 11455.71
## 4: 17 1 205.1594 -0.007142357 0.977 NA 6405 6586 14695.59
## 5: 18 1 260.7958 -0.010542321 0.962 NA 6804 6985 15236.11
## 6: 20 1 249.3327 -0.009140158 0.975 NA 7602 7783 16315.95
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 9002.23 99.692 98.585 -0.004274315 -0.001719574 -0.002554741 -0.002554741
## 2: 10081.72 99.756 98.724 -0.004397465 -0.002278889 -0.002118576 -0.002118576
## 3: 11700.65 99.809 97.701 -0.008233730 -0.003118013 -0.005115717 -0.005115717
## 4: 14940.81 100.070 98.458 -0.007142357 -0.004796909 -0.002345448 -0.002345448
## 5: 15480.90 99.870 97.657 -0.010542321 -0.005076881 -0.005465439 -0.005465439
## 6: 16561.19 100.110 97.788 -0.009140158 -0.005636544 -0.003503615 -0.003503615
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.02888637
## 2: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.02395467
## 3: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.05784324
## 4: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.02651990
## 5: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.06179754
## 6: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.03961526
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -112.61744 NA mgO2/hr/kg -112.61744
## 2: -93.39051 NA mgO2/hr/kg -93.39051
## 3: -225.50970 NA mgO2/hr/kg -225.50970
## 4: -103.39144 NA mgO2/hr/kg -103.39144
## 5: -240.92609 NA mgO2/hr/kg -240.92609
## 6: -154.44545 NA mgO2/hr/kg -154.44545
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 7 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0002565 | ch2 | Asus | 0.04958 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 167.378 | 0.0429325 | 0.9796 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.61
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 6 7 9 10 11 12 13 16 17 18 20 21 22 24 25 26
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.44
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 257.4988 -0.029028116 0.9975095 NA 94 139 5475.19
## 2: NA 2 257.0864 -0.028952899 0.9972661 NA 95 140 5476.53
## 3: NA 3 257.0037 -0.028938423 0.9972831 NA 93 138 5473.85
## 4: NA 4 256.5828 -0.028862457 0.9968949 NA 92 137 5472.49
## 5: NA 5 256.1065 -0.028776324 0.9965110 NA 91 136 5471.14
## ---
## 174: NA 174 137.3189 -0.007322031 0.9181888 NA 155 200 5557.67
## 175: NA 175 137.1060 -0.007284417 0.9198187 NA 156 201 5559.02
## 176: NA 176 137.0045 -0.007267490 0.9191133 NA 159 204 5563.09
## 177: NA 177 136.6798 -0.007208929 0.9217806 NA 158 203 5561.74
## 178: NA 178 136.5556 -0.007186307 0.9225430 NA 157 202 5560.38
## endtime oxy endoxy rate
## 1: 5535.19 98.534 96.833 -0.029028116
## 2: 5536.53 98.526 96.842 -0.028952899
## 3: 5533.85 98.539 96.908 -0.028938423
## 4: 5532.49 98.580 96.936 -0.028862457
## 5: 5531.14 98.615 96.999 -0.028776324
## ---
## 174: 5617.67 96.712 96.151 -0.007322031
## 175: 5619.02 96.690 96.123 -0.007284417
## 176: 5623.09 96.631 96.065 -0.007267490
## 177: 5621.74 96.639 96.098 -0.007208929
## 178: 5620.38 96.673 96.143 -0.007186307
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.02902812
## Adjustment : 0.0005683739
## Adjusted Rate : -0.02959649
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 84 rate(s) removed, 94 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 93 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 257.4988 -0.02902812 0.9975095 NA 94 139 5475.19
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 5535.19 98.534 96.833 -0.02902812 0.0005683739 -0.02959649 -0.02959649
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04958 0.0002565 NA 36 28.5 1.013253 -0.3346465
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1304.665 NA mgO2/hr/kg -1304.665
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 7 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0002565 | ch2 | Asus | 0.04958 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 167.378 | 0.0429325 | 0.9796 | 1304.665 | 0.3346465 | 0.9975095 | 1137.287 | 0.2917141 | check max | |
| ### Expor | ting data |
## Rows: 330 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 8
mass = 0.0004561
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_asus
system1 = "Asus"
Notes="check max; probe got bumped; reliable?"
##--- time of trail ---##
experiment_mmr_date_asus <- "16 March 2023 01 00PM/Oxygen"
experiment_mmr_date2_asus <- "16 March 2023 01 00PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.000391705
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
#bg_post3 <- post_cycle3 %>% calc_rate.bg()
bg_post <- mean(bg_post1$rate.bg.mean,bg_post2$rate.bg.mean) #,bg_post3$rate.bg.mean)
bg_post ## [1] -0.00199299
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.61
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.45
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=15,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 12 1 207.0437 -0.009322762 0.981 NA 4410 4591 11995.53
## 2: 13 1 225.5471 -0.010376465 0.975 NA 4810 4991 12536.57
## 3: 14 1 245.5563 -0.011462953 0.981 NA 5208 5389 13075.50
## 4: 15 1 247.7332 -0.011172244 0.972 NA 5607 5788 13615.63
## 5: 16 1 253.4136 -0.011152938 0.961 NA 6006 6187 14155.51
## 6: 17 1 269.4809 -0.011844878 0.968 NA 6405 6586 14695.59
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 12240.60 95.096 92.632 -0.009322762 -0.001884560 -0.007438202 -0.007438202
## 2: 12781.71 95.187 92.901 -0.010376465 -0.001990091 -0.008386373 -0.008386373
## 3: 13320.31 95.284 92.782 -0.011462953 -0.002095173 -0.009367780 -0.009367780
## 4: 13860.56 95.204 92.589 -0.011172244 -0.002200532 -0.008971713 -0.008971713
## 5: 14400.26 95.426 92.438 -0.011152938 -0.002305813 -0.008847125 -0.008847125
## 6: 14940.81 95.185 92.177 -0.011844878 -0.002411196 -0.009433682 -0.009433682
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.07743697
## 2: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.08730811
## 3: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.09752525
## 4: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.09340191
## 5: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.09210486
## 6: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.09821133
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -169.7807 NA mgO2/hr/kg -169.7807
## 2: -191.4232 NA mgO2/hr/kg -191.4232
## 3: -213.8243 NA mgO2/hr/kg -213.8243
## 4: -204.7838 NA mgO2/hr/kg -204.7838
## 5: -201.9401 NA mgO2/hr/kg -201.9401
## 6: -215.3285 NA mgO2/hr/kg -215.3285
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 8 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004561 | ch1 | Asus | 0.04565 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 205.46 | 0.0937103 | 0.9714 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.61
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 22
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.41
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 315.4916 -0.03629665 0.9936658 NA 34 79 6086.70
## 2: NA 2 314.6000 -0.03615033 0.9930439 NA 35 80 6088.07
## 3: NA 3 314.5739 -0.03614912 0.9935123 NA 28 73 6078.59
## 4: NA 4 314.5133 -0.03613714 0.9931384 NA 33 78 6085.33
## 5: NA 5 314.2956 -0.03610304 0.9933272 NA 29 74 6079.94
## ---
## 173: NA 173 226.7768 -0.02198785 0.9632938 NA 163 208 6260.99
## 174: NA 174 225.9683 -0.02185838 0.9630053 NA 159 204 6255.61
## 175: NA 175 225.7862 -0.02183026 0.9631198 NA 162 207 6259.66
## 176: NA 176 225.2597 -0.02174605 0.9634269 NA 160 205 6256.96
## 177: NA 177 225.0003 -0.02170499 0.9634336 NA 161 206 6258.31
## endtime oxy endoxy rate
## 1: 6146.70 94.500 92.412 -0.03629665
## 2: 6148.07 94.505 92.453 -0.03615033
## 3: 6138.59 94.783 92.716 -0.03614912
## 4: 6145.33 94.577 92.446 -0.03613714
## 5: 6139.94 94.766 92.705 -0.03610304
## ---
## 173: 6320.99 89.106 87.742 -0.02198785
## 174: 6315.61 89.314 87.981 -0.02185838
## 175: 6319.66 89.168 87.756 -0.02183026
## 176: 6316.96 89.296 87.861 -0.02174605
## 177: 6318.31 89.218 87.844 -0.02170499
##
## Regressions : 177 | Results : 177 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 177 adjusted rate(s):
## Rate : -0.03629665
## Adjustment : -0.000391705
## Adjusted Rate : -0.03590494
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 177 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 176 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 315.4916 -0.03629665 0.9936658 NA 34 79 6086.7
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6146.7 94.5 92.412 -0.03629665 -0.000391705 -0.03590494 -0.03590494
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0004561 NA 36 28.5 1.013253 -0.373796
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -819.5483 NA mgO2/hr/kg -819.5483
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 8 | CVLA049 | CVLA098 | Vlassof cay | 109 | 0.0004561 | ch1 | Asus | 0.04565 | 2023-03-16 | 2024-06-27 | good/good | 36 | 28.5 | 205.46 | 0.0937103 | 0.9714 | 819.5483 | 0.373796 | 0.9936658 | 614.0883 | 0.2800857 | check max; probe got bumped; reliable? | |
| ### Expor | ting data |
## Rows: 331 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.